#include "files/file_manager.h"

namespace Tvimeg
{
	FileManager::FileManager(void)
	{
	}

	FileManager::~FileManager(void)
	{
	}

	void FileManager::Initialise(void)
	{
		const size_t BUFFER_SIZE = 4 * 1024;
		char buffer[BUFFER_SIZE];
		const char* tempString = getcwd(buffer, BUFFER_SIZE);

		if(tempString == NULL)
		{
			const size_t LARGE_BUFFER_SIZE = 128 * 1024;
			char* largeBuffer = new char[LARGE_BUFFER_SIZE];
			const char* largeString = getcwd(largeBuffer, LARGE_BUFFER_SIZE);

			if(largeString != NULL)
			{
				workingDirectory = Directory(largeString);
			}

			delete [] largeBuffer;
		}
		else
		{
			workingDirectory = Directory(tempString);
		}
	}

	const Directory& FileManager::GetWorkingDirectory(void) const
	{
		return workingDirectory;
	}
}
